'''
假设北京到天津有以下4个车次可供选择
用户选择所要购买的车次，进行购票进展
'''

#我的方法
'''
#打印车次信
a =[]
print("车次 出发地-达到站  出发时间  到站时间  运行时长")
lst = [
    ["G1569","北京南-天津南","18:06","18:39","00:33"],
    ["G1567","北京南-天津南","18:15","18:49","00:34"],
    ["G8917","北京南-天津南","18:20","18:39","00:19"],
    ["G203","北京南-天津南","18:35","19:09","00:34"],
]
for item in lst:
    print(" ".join(item))
#用户输入要选择购买的车次
change = input("请输入你要选择的车次：")
#输入乘车人信息
a = input("请输入要乘车的姓名，如有多名乘客请用逗号隔开：").split("，")
#打印所购买车次的信息
for item1 in lst:
    for item2 in item1:
        if change == item2:
            print("购票成功",item2)
            break
        else:
            print("失败")
            break
'''
#创建字典存储车票信息,组合数据类型
dict_ticket = {
    "G1569":["北京南-天津南","18:06","18:39","00:33"],
    "G1567":["北京南-天津南","18:15","18:49","00:34"],
    "G8917":["北京南-天津南","18:20","18:39","00:19"],
    "G203":["北京南-天津南","18:35","19:09","00:34"],
}
print("车次    出发地-达到站    出发时间    到站时间    运行时长")
#遍历字典的值
for key in dict_ticket.keys():
    print(key,end='  ')
    for item in dict_ticket.get(key):
        print(item,end='     ')
    print()
#用户输入要选择购买的车次
train = input("请输入你要选择的车次：")
#根据key来获取值
info = dict_ticket.get(train,'车次不存在')
if info != "车次不存在":
    person = input("请输入要乘车的姓名，如有多名乘客请用逗号隔开：")
    s = info[0] + ' ' + info[1] + "开"
    print("您已购买"+train+' '+s+"请"+person+"尽快赶到火车站")
else:
    print("对不起，选择的车次可能不存在")